package com.sts.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.sts.bean.User1;

@Repository
public class U2Dao implements I2user {
	
	@Resource
	private SqlSessionFactory sqlSessionFactory;
	
	Logger log = Logger.getLogger(this.getClass());

	@Override
	public User1 selectUser2(Map<String, Object> map) {
		log.debug("user1 dao selectUser2 in");
		log.debug(map);
		
		User1 user = new User1() ;
		SqlSession session = sqlSessionFactory.openSession();
		I2user i2u = session.getMapper(I2user.class) ;
		user = i2u.selectUser2(map) ;
		log.debug("user1 dao selectUser2 out");
		return user;
	}

	@Override
	public List<User1> selectUser1List(Map<String, Object> map) {
		
		List<User1> list = new ArrayList<User1>() ;
		log.debug("user1 dao selectUser2 in");
		log.debug(map);
		
		SqlSession session = sqlSessionFactory.openSession();
		I2user i2u = session.getMapper(I2user.class) ;
		list = i2u.selectUser1List(map) ;
		log.debug("user1 dao selectUser2 out");
		return list;
	}

	@Override
	public int deleteUser(String id) {
		log.debug("user1 dao deleteUser in");
		SqlSession session = sqlSessionFactory.openSession();
		I2user i2u = session.getMapper(I2user.class) ;
		int result = i2u.deleteUser(id) ;
		log.debug("user1 dao deleteUser out");
		return result;
	}

	@Override
	public int selectSize(Map<String, Object> map) {

		log.debug("user1 dao deleteUser in");
		SqlSession session = sqlSessionFactory.openSession();
		I2user i2u = session.getMapper(I2user.class) ;
		int result = i2u.selectSize(map) ;
		
		return result;
	}

	@Override
	public int insertUser1(User1 user) {
		SqlSession session = sqlSessionFactory.openSession();
		I2user i2u = session.getMapper(I2user.class) ;
		int result = i2u.insertUser1(user);
		return result;
	}

	@Override
	public int updateUser(User1 user) {
		SqlSession session = sqlSessionFactory.openSession();
		I2user i2u = session.getMapper(I2user.class) ;
		int result = i2u.updateUser(user);
		return result;
	}

}
